	
// DatoNotat.h : Declaration of the CDatoNotat

#ifndef __DATONOTAT_H_
#define __DATONOTAT_H_

#include "resource.h"       // main symbols
#include "importado.h"
#include "database.h"
#include "ErrorHandling.h"

/////////////////////////////////////////////////////////////////////////////
// CDatoNotat
class ATL_NO_VTABLE CDatoNotat : 
	public CComObjectRootEx<CComMultiThreadModel>,
	public CComCoClass<CDatoNotat, &CLSID_DatoNotat>,
	public ISupportErrorInfo,
	public IDispatchImpl<IDatoNotat, &IID_IDatoNotat, &LIBID_EBASDLLLib>
{
public:
	CDatoNotat()
	{
		m_pUnkMarshaler = NULL;
		m_recordset = NULL;
	}
	virtual ~CDatoNotat()
	{
		if (m_recordset)
			m_recordset->Close();
	}

DECLARE_REGISTRY_RESOURCEID(IDR_DATONOTAT)
DECLARE_GET_CONTROLLING_UNKNOWN()

DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CDatoNotat)
	COM_INTERFACE_ENTRY(IDatoNotat)
	COM_INTERFACE_ENTRY(IDispatch)
	COM_INTERFACE_ENTRY(ISupportErrorInfo)
	COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
END_COM_MAP()

	HRESULT FinalConstruct()
	{
		return CoCreateFreeThreadedMarshaler(
			GetControllingUnknown(), &m_pUnkMarshaler.p);
	}

	void FinalRelease()
	{
		m_pUnkMarshaler.Release();
	}

	CComPtr<IUnknown> m_pUnkMarshaler;

// ISupportsErrorInfo
	STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);

// IDatoNotat
public:
	STDMETHOD(get_FilNavn)(/*[out, retval]*/ BSTR *pVal);
	STDMETHOD(put_FilNavn)(/*[in]*/ BSTR newVal);
	STDMETHOD(SetInfo)();
	STDMETHOD(get_StuderendeGuid)(/*[out, retval]*/ BSTR *pVal);
	STDMETHOD(put_StuderendeGuid)(/*[in]*/ BSTR newVal);
	STDMETHOD(get_Notat)(/*[out, retval]*/ VARIANT *pVal);
	STDMETHOD(put_Notat)(/*[in]*/ VARIANT newVal);
	STDMETHOD(get_Emne)(/*[out, retval]*/ BSTR *pVal);
	STDMETHOD(put_Emne)(/*[in]*/ BSTR newVal);
	STDMETHOD(get_Dato)(/*[out, retval]*/ BSTR *pVal);
	STDMETHOD(put_Dato)(/*[in]*/ BSTR newVal);
	STDMETHOD(get_GUID)(/*[out, retval]*/ BSTR *pVal);
	STDMETHOD(put_GUID)(/*[in]*/ BSTR newVal);
private:
	bstr_t m_guid, m_dato, m_emne, m_studGuid, m_filNavn;
	_RecordsetPtr m_recordset;
	_variant_t m_notat; // consider the use of lazy-fetch instead
};

#endif //__DATONOTAT_H_
